package com.zhouyer.pojo;

import java.util.Objects;

public enum SqlCommandType {
    SELECT(1, "select"),
    INSERT(2, "insert"),
    UPDATE(3, "update"),
    DELETE(4, "delete");
    /*
     * 代码值
     */
    private Integer code;
    /*
     * 标签
     */
    private String tag;

    SqlCommandType(Integer code, String tag) {
        this.code = code;
        this.tag = tag;
    }

    public Integer getCode() {
        return code;
    }

    public String getTag() {
        return tag;
    }

    public static SqlCommandType getSqlCommandTypeByTag(String tag) {
        for (SqlCommandType sqlCommandType : SqlCommandType.values()) {
            if (Objects.equals(sqlCommandType.getTag(), tag))
                return sqlCommandType;
        }
        return null;
    }
}
